// 房间类的具体实现（实现头文件中的蓝图）|| Concrete implementation of Room class (fulfilling the blueprint in header)
#include "Room.hh"

// ====== 房间建造指南 ====== || ====== Room Construction Guide ======
// 实际建造房间的方法（根据设计图施工）|| Actual room construction method (building according to blueprint)
Room::Room(std::string desc, std::string t) 
    : description(desc),      // 注入房间描述 || Inject room description
      task(t),                // 设置任务要求 || Set mission objective
      taskCompleted(false),   // 初始任务未完成 || Initial mission incomplete
      north(nullptr),         // 北门初始无连接 || North door initially unconnected
      south(nullptr),         // 南门初始无连接 || South door initially unconnected
      east(nullptr),          // 东门初始无连接 || East door initially unconnected
      west(nullptr) {}        // 西门初始无连接 || West door initially unconnected

// ====== 房间拆除流程 ====== || ====== Room Demolition Process ======
Room::~Room() {
    // 清理物品收纳盒（逐个删除道具）|| Clean item container (delete items one by one)
    for (Item* item : items) {
        delete item;  // 销毁道具释放内存 || Destroy item to free memory
    }
    
    // 清理敌人名单（逐个消灭敌人）|| Clear enemy roster (eliminate enemies one by one)
    for (ICharacter* enemy : enemies) {
        delete enemy; // 消灭敌人释放内存 || Eliminate enemy to free memory
    }
}

// ====== 连接房间系统 ====== || ====== Room Connection System ======
// 安装四向门牌（连接其他房间）|| Install directional doors (connect to other rooms)
void Room::setExits(Room* n, Room* s, Room* e, Room* w) {
    north = n;  // 设置北门通向参数房间 || Set north door leads to parameter room
    south = s;  // 设置南门通向参数房间 || Set south door leads to parameter room
    east = e;   // 设置东门通向参数房间 || Set east door leads to parameter room
    west = w;   // 设置西门通向参数房间 || Set west door leads to parameter room
}

// ====== 内容管理系统 ====== || ====== Content Management System ======
// 放入道具到收纳盒（添加到列表末尾）|| Place item into container (add to list end)
void Room::addItem(Item* item) { items.push_back(item); }

// 添加敌人到名单（加入列表末尾）|| Add enemy to roster (append to list end)
void Room::addEnemy(ICharacter* enemy) { enemies.push_back(enemy); }

// ====== 信息查询接口 ====== || ====== Information Query Interface ======
// 获取房间描述（返回描述文本）|| Get room description (return text)
std::string Room::getDescription() const { return description; }

// 获取各方向门牌信息（返回对应房间地址）|| Get door information (return connected room address)
Room* Room::getNorth() const { return north; }  // 北门去向 || North exit
Room* Room::getSouth() const { return south; }  // 南门去向 || South exit
Room* Room::getEast() const { return east; }    // 东门去向 || East exit
Room* Room::getWest() const { return west; }    // 西门去向 || West exit

// 获取物品收纳盒（允许外部操作内部道具）|| Get item container (allow external manipulation)
std::vector<Item*>& Room::getItems() { return items; }

// 获取敌人名单（允许外部操作敌人数据）|| Get enemy roster (allow external modifications)
std::vector<ICharacter*>& Room::getEnemies() { return enemies; }